//
//  PNodeIndicator.m
//  ProjectL
//
//  Created by Nguyen Tan Loc on 8/22/13.
//  Copyright (c) 2013 Nguyen Tan Loc. All rights reserved.
//

#import "PNodeIndicator.h"
#import "LevelManager.h"

@implementation PNodeIndicator
@synthesize _node = mNode;

-(id) initWithNode:(PNode *)node
{
    if (self = [super initWithSpriteFrameName:[self getSpriteFrameName]])
    {
        mNode = node;
        CCFadeTo *fadeTo1 = [CCFadeTo actionWithDuration:0.5 opacity:100];
        CCFadeTo *fadeTo2 = [CCFadeTo actionWithDuration:0.5 opacity:255];
        CCSequence *sequence = [CCSequence actionOne:fadeTo1 two:fadeTo2];
        CCRepeatForever *repeatForever = [CCRepeatForever actionWithAction:sequence];
        [self runAction:repeatForever];
        [self setColor:[[LevelManager getInstance] getWorldColor]];
        
        [self scheduleUpdate];
    }
    
    return self;
}

-(void) update:(ccTime)delta
{
    [self setPosition:[mNode getRealPosition]];
}

-(NSString *) getSpriteFrameName
{
    return SFN_NODE_INDICATOR;
}

@end
